package com.store.practice.controller;

import com.store.practice.common.api.CommonPage;
import com.store.practice.common.api.CommonResult;
import com.store.practice.service.StaffManageService;
import com.store.practice.service.StoreOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api(tags = "StaffManageController",description = "员工管理")
@RestController
@RequestMapping("/storeStaff")
public class StaffManageController {
    @Autowired
    private StaffManageService staffManageService;

    @ApiOperation("展示员工信息")
    @GetMapping("/list")
    public CommonResult list(Integer storeId,Integer pageSize,Integer pageNum){
        List<Map> result = staffManageService.list(storeId,pageSize,pageNum);
        if (result==null){
            return CommonResult.failed();
        }
        return CommonResult.success(CommonPage.restPage(result));
    }

    @ApiOperation("展示员工详情")
    @GetMapping("/getStaff")
    public CommonResult getStaff(Integer id){
        Map result = staffManageService.getStaff(id);
        return CommonResult.success(result);
    }

    @ApiOperation("操作员工离职复职")
    @PostMapping("/updateWorkStatus")
    public CommonResult updateWorkStatus(Integer id,Integer param){
        int i = staffManageService.updateWorkStatus(id, param);
        if (i>0){
            return CommonResult.success(i);
        }
        return CommonResult.failed();
    }

    @ApiOperation("展示待审核员工列表")
    @GetMapping("/listAudit")
    public CommonResult listAudit(){
        //todo
        return null;
    }

    @ApiOperation("审核员工")
    @PostMapping("/audit")
    public CommonResult audit(Integer param){
        //todo
        return null;
    }
}
